<%= content_tag_for :li, config_group, (added ? :selected : nil), :id => "config_group_#{config_group.id}", :class => css_class.to_s do %>
  <%= hidden_field_tag("#{type}[config_group_ids][]", config_group.id) if added == 'manually' %>
  <span>
   <%= link_to(icon_text('plus', config_group.name), '#', :rel=>'twipsy', :class => 'config_group_name',
           :onclick => "tfm.classEditor.expandClassList($(this), '#cgroup_#{config_group.id}')",
           :data => {:puppetclass_ids => config_group.puppetclass_ids,
                    :'group-id' => config_group.id,
                    :id => config_group.id,
                    :type => type,
                    :'original-title' => (obj.parent_config_groups.include?(config_group) ? _('included already from parent') : '' )
                  }
              ) %>
  </span>
  <%= link_to(" #{added ? _('Remove') : _('Add')}", '#', :rel=>'twipsy', :class => "btn btn-default btn-sm glyphicon glyphicon-#{added ? 'minus' : 'plus'}-sign",
          :onclick => (added ? 'tfm.classEditor.removeConfigGroup(this)' : 'tfm.classEditor.addConfigGroup(this)'),
          :data => {:puppetclass_ids => config_group.puppetclass_ids,
                    :'group-id' => config_group.id,
                    :id => config_group.id,
                    :type => type
                   }
             ) unless obj.parent_config_groups.include?(config_group) %>

  <ul class='hide' id='<%= "cgroup_" + config_group.id.to_s %>'>
    <% config_group.puppetclasses.each do |cg_puppetclass|%>
          <% css_class = class_in_environment?(obj.try(:environment),cg_puppetclass) ? '' : 'lightgray' %>
          <% tip = css_class == 'lightgray' ? (_("%s is not in environment") % (cg_puppetclass.name)) : '' %>
          <li>
            <%= content_tag(:span, :class => css_class, :'data-original-title' => tip, :rel => "twipsy") do %>
              <%= cg_puppetclass.name %>
            <% end %>
          </li>
    <% end %>
  </ul>
<% end %>
